/**
 * Copyright (c) 2010-2011 julewa.com.  
 * All rights reserved. 
 * 
 * @author Huang Benhua
 * @date 2011-2-20
 * 
**/
package com.julewa.loading;

import java.util.HashSet;
import java.util.Set;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public final class PreInterceptor {
	Set<String> statics = new HashSet<String>(); 
	public PreInterceptor(){
		String confs[] = SystemUtils.getProperty("system.uri.statics", "").split(",");
		for(String c:confs){
			if(c == null || c.trim().equals(""))continue;
			statics.add(c.trim());
		} 
	}
	
	public boolean before(HttpServletRequest request,HttpServletResponse response){
		//
		String uri = request.getServletPath().substring(1);
		int idx = uri.indexOf('/');
		if(idx > 0){
			uri = uri.substring(0, idx);
		}
		if(statics.contains(uri))return false;
		return true;
	}
	
	public void after(HttpServletRequest request,HttpServletResponse response){
		
	};
 
}
